home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
utilities
/
icon_1.0
/
source
/
icon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-17
|
26KB
|
1,275 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1990 by Olaf Barthel & MXM
*
* Name .....: Icon.c
* Created ..: Friday 10-May-91 16:58
* Revision .: 0
*
* Date Author Comment
* ========= ======== ====================
* 10-May-91 Olsen Created this file!
*
* $Revision Header ********************************************************/
/* A quick set of file types we are able to provide icons for. */
enum { TYPE_DIR,TYPE_FILE,TYPE_ICON,
TYPE_TEXT,
TYPE_C,TYPE_H,
TYPE_ASM,TYPE_I,
TYPE_MOD,
TYPE_REXX,
TYPE_BASIC,
TYPE_TEX,TYPE_METAFONT,TYPE_GF,TYPE_TEXFONT,TYPE_TEXDVI,TYPE_FLIB,
TYPE_OLDMANX,TYPE_NEWMANX,TYPE_OLDMANXLIB,TYPE_NEWMANXLIB,
TYPE_OBJECT,TYPE_LIB,
TYPE_EXECUTABLE,
TYPE_LIBRARY,TYPE_DEVICE,TYPE_FILESYS,TYPE_HANDLER,
TYPE_GIF,TYPE_ILBM,TYPE_ANIM,TYPE_8SVX,TYPE_SMUS,TYPE_FTXT,TYPE_PREFS,TYPE_TERM,
TYPE_IMPLODER,TYPE_POWERPACKER,
TYPE_ARC,TYPE_LHARC,TYPE_ZOO,TYPE_ZIP,TYPE_DMS,TYPE_WARP,TYPE_ZOOM,
};
/* Name of the global handshake port. */
#define PORTNAME "Icon Rendezvous"
/* Library vector offsets for a bunch of routines. */
#define EXAMINE -102
#define EXNEXT -108
#define OPEN -30
#define CLEARMENUSTRIP -54
/* This structure describes the global handshake port. */
struct IconPort
{
struct MsgPort VanillaPort;
BPTR Segment;
VOID (*Remove)();
};
/* A structure containing both a file name suffix and the
* approriate file type.
*/
struct Suffix
{
UBYTE *Name;
UBYTE Type;
};
/* A structure containing an icon file name and a special
* purpose flag.
*/
struct NameInfo
{
UBYTE *Name;
BYTE IsPresent;
};
/* A table of valid ASCII characters (7 bits). */
BYTE ValidTab[256] =
{
0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,
0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/* A table of clearly invalid ASCII characters (8 bits). */
BYTE InvalidTab[256] =
{
1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,
1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/* Some file name suffixes for text files and the approriate
* file types.
*/
struct Suffix TextSuffix[] =
{
".C", TYPE_C,
".CP", TYPE_C,
".CC", TYPE_C,
".H", TYPE_H,
".ASM", TYPE_ASM,
".A", TYPE_ASM,
".S", TYPE_ASM,
".I", TYPE_I,
".BAS", TYPE_BASIC,
".GFA", TYPE_BASIC,
".REXX",TYPE_REXX,
".CED", TYPE_REXX,
".VLT", TYPE_REXX,
".CPR", TYPE_REXX,
".TxEd",TYPE_REXX,
".TEX", TYPE_TEX,
".STY", TYPE_TEX,
".MF", TYPE_METAFONT,
".MOD", TYPE_MOD,
".DEF", TYPE_MOD
};
/* Some more file name suffixes for executable files and the
* approriate file types.
*/
struct Suffix ExecutableSuffix[] =
{
".device", TYPE_DEVICE,
".library", TYPE_LIBRARY,
"FileSystem", TYPE_FILESYS,
"Handler", TYPE_HANDLER
};
/* This list contains the names of all icon files which can be
* attached to the files to be identified. The flag byte indicates
* whether an icon is available or not.
*/
struct NameInfo NameInfo[] =
{
NULL, FALSE,
NULL, FALSE,
NULL, FALSE,
"text", FALSE,
"c", FALSE,
"h", FALSE,
"asm", FALSE,
"i", FALSE,
"mod", FALSE,
"rexx", FALSE,
"basic", FALSE,
"tex", FALSE,
"metafont", FALSE,
"gf", FALSE,
"pk", FALSE,
"dvi", FALSE,
"flib", FALSE,
"manx3object", FALSE,
"manx5object", FALSE,
"manx3lib", FALSE,
"manx5lib", FALSE,
"object", FALSE,
"lib", FALSE,
NULL, FALSE,
"library", FALSE,
"device", FALSE,
"filesys", FALSE,
"handler", FALSE,
"gif", FALSE,
"pic", FALSE,
"anim", FALSE,
"sound", FALSE,
"score", FALSE,
"ftxt", FALSE,
"pref", FALSE,
"term", FALSE,
"imploder", FALSE,
"powerpacker", FALSE,
"arc", FALSE,
"lharc", FALSE,
"zoo", FALSE,
"zip", FALSE,
"dms", FALSE,
"warp", FALSE,
"zoom", FALSE
};
/* Prototypes for functions in this module and Bypass.asm */
extern LONG __asm MyExamine(register __d1 BPTR FileLock,register __d2 struct FileInfoBlock *FileInfo);
LONG __saveds __asm NewExamine(register __d1 BPTR FileLock,register __d2 struct FileInfoBlock *FileInfo);
extern LONG __asm MyExNext(register __d1 BPTR FileLock,register __d2 struct FileInfoBlock *FileInfo);
LONG __saveds __asm NewExNext(register __d1 BPTR FileLock,register __d2 struct FileInfoBlock *FileInfo);
extern BPTR __asm MyOpen(register __d1 UBYTE *Name,register __d2 LONG Mode);
BPTR __saveds __asm NewOpen(register __d1 UBYTE *Name,register __d2 LONG Mode);
extern VOID __asm MyClearMenuStrip(register __a0 struct Window *Window);
VOID __saveds __asm NewClearMenuStrip(register __a0 struct Window *Window);
VOID __saveds RemoveIcon(VOID);
BYTE InstallIcon(VOID);
struct Node * MyFindName(struct List *List,UBYTE *Name);
UBYTE Local2Upper(UBYTE c);
UBYTE StrCmp(UBYTE *a,UBYTE *b);
VOID DeleteNode(struct Node *Node);
struct Node * CreateNode(UBYTE *Name);
VOID AddName(UBYTE *FileName,UBYTE Type);
ULONG __saveds Main(VOID);
/* Global and shared library identifiers. */
struct ExecBase *SysBase;
struct DosLibrary *DOSBase;
struct IntuitionBase *IntuitionBase;
/* Pointers to the old library routines. */
APTR OldExamine;
APTR OldExNext;
APTR OldOpen;
APTR OldClearMenuStrip;
/* The list containing the files which do not have an icon and the
* access semaphore.
*/
struct SignalSemaphore NameSemaphore;
struct List NameList;
/* The node being scanned. */
struct Node *ScanNode;
/* True if ExNext is to perform fake scanning, else false. */
BYTE FakeScan;
/* Global handshake port. */
struct IconPort *IconPort;
/* Main():
*
* Program entry point.
*/
ULONG __saveds
Main()
{
struct Process *ThisProcess;
/* Set up SysBase. */
SysBase = *(struct ExecBase **)4;
/* Look who we are. */
ThisProcess = (struct Process *)SysBase -> ThisTask;
/* Started from Shell? */
if(ThisProcess -> pr_CLI)
{
/* Open the DOS library. */
if(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",36))
{
Printf("\33[1m\33[33mIcon\33[31m © \33[0mCopyright 1991 by Olaf Barthel, ");
/* If the port is available remove an
* already running `Icon'.
*/
if(IconPort = (struct IconPort *)FindPort(PORTNAME))
{
Flush(ThisProcess -> pr_COS);
Printf("Removing patch... ");
Flush(ThisProcess -> pr_COS);
Forbid();
IconPort -> Remove();
Permit();
Printf("done.\n");
CloseLibrary(DOSBase);
}
else
{
/* Install `Icon'. */
Flush(ThisProcess -> pr_COS);
Printf("Installing patch... ");
Flush(ThisProcess -> pr_COS);
if(InstallIcon())
Printf("done.\n");
else
{
Printf("failed!\a\n");
CloseLibrary(DOSBase);
}
}
}
else
return(RETURN_FAIL);
}
else
{
struct Message *Message;
/* Wait for Workbench startup message. */
Message = (struct Message *)WaitPort(&ThisProcess -> pr_MsgPort);
Forbid();
/* And reply it. */
ReplyMsg(Message);
}
return(RETURN_OK);
}
/* MyFindName(struct List *List,UBYTE *Name):
*
* Find a node in a list, scan for the name ignoring
* case.
*/
struct Node *
MyFindName(struct List *List,UBYTE *Name)
{
struct Node *Node;
Node = List -> lh_Head;
while(Node -> ln_Succ)
{
if(!StrCmp(Node -> ln_Name,Name))
return(Node);
Node = Node -> ln_Succ;
}
return(NULL);
}
/* Rem